<?php 
/**
 * @file entry.php
 * @author LD <2009-10-28 11:57:12>
 * @package kbao
 * @desc 
 *   交易程序入口
 */

require_once 'setting.php';

/**
 * 01. 得到用户ID, IM滴session
 */
global $gLD;
$gLD['module'] = check($_GET['module']);
$gLD['user_id'] = check($_GET['uin']);
$gLD['sessionKey'] = check($_GET['sessionKey']);

/**
 * 02. 验证IM、用户自服务平台登录与否
 */
$isLogin = Appleseed::isLogin($gLD['user_id'], $gLD['sessionKey']);
if ( !empty($gLD['user_id']) and $isLogin['result'] ){
	
	$gLD['user_nick'] = $isLogin['user_nick'];
	$gLD['user_snick'] = $isLogin['user_snick'];
	
}else {
	$gLD['msg'] = "First Login Failed...";
	require_once 'view/V403.php';
	exit;
}


/**
 * 03. 是否已经登陆
 */
$gLD['BlackHole'] = Appleseed::getBlackHole();
if ( $gLD['module'] != 'login' ) {
	$anti = validaStatus(); //校验登陆,默认跳入登录页面

	/* 确认跳转与否 */
	if ($anti == 1 ){
		header("LOCATION:?black%20hole={$gLD['BlackHole']}&sessionKey={$gLD['sessionKey']}&uin={$gLD['user_id']}&module=login");
		exit;
	}
}

/**
 * 04. 开始module的抉择
 */
switch ($gLD['module']) {
	case 'login': //登陆窗口
		require_once 'login.php';
		break;
	case 'chgpswd': //修改安全密码
		require_once 'changePassword.php';
		break;	
	case 'aa': //账户管理
		require_once 'aa.php';
		break;
	case 'bb': //交易委托
		$gLD['sys_options'] = Appleseed::getOptions();
		if ( empty($gLD['sys_options']) ){
			$gLD['msg'] = "Empty System Options...";
			require_once 'view/V403.php';
			exit;
		}else{
			require_once 'bb.php';
		}
		break;
	case 'cc': //交易查询
		require_once 'cc.php';
		break;
		
	default:
		$gLD['msg'] = "Module Miss...";
		require_once 'view/V403.php';
		break;
}

?>